package com.book.backend.controller.ai;

import com.aliyun.broadscope.bailian.sdk.consts.HttpHeaderConsts;
import com.book.backend.service.AiService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/ai")
public class AIController {
    @Resource
    private AiService aiService;

    @GetMapping(value = "/stream"
//            , produces = HttpHeaderConsts.MediaType.TEXT_EVENT_STREAM_VALUE
    )
    @ApiOperation("ai流式输出")
    public SseEmitter streamOutput(@RequestParam String msg) throws IOException {
        System.out.println(msg+"*()*");
        return aiService.outPut(msg);
    }
}
